/**
 * Creater with IntelliJ IDEA.
 * Description:
 * User: 86152
 * Dae: 2022-07-27
 * Time: 16:33
 */
public class demo2 {
    public static void main(String[] args) throws InterruptedException {
        Object o = new Object();
        for(int i=0;i<10;i++) {
            Thread t1 = new Thread("A") {
                @Override
                public void run() {
                    synchronized (o) {
                        System.out.print(this.getName());
                    }
                }
            };
            Thread t2 = new Thread("B") {
                @Override
                public void run() {
                    synchronized (o) {
                        System.out.print(this.getName());
                    }
                }
            };
            Thread t3 = new Thread("C") {
                @Override
                public void run() {
                    synchronized (o) {
                        System.out.print(this.getName());
                    }
                }
            };
            t1.start();
            t1.join();
            t2.start();
            t2.join();
            t3.start();
            t3.join();
            System.out.println();
        }
    }
}
